<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

    protected function _initAutoload() {
        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->registerNamespace('Twig_');

        $loader = $this->getResourceLoader();
        $loader->addResourceType('extention', 'views/extentions', 'TwigExtention');
        $loader->addResourceType('helpers', 'helpers', 'Helper');

        Zend_Controller_Action_HelperBroker::addPath('helpers', 'Jhg_Helper');
    }

    protected function _initView() {
        $this->bootstrap('twig');
        $twig = $this->getResource('twig');
        $twig->addExtention(new Jhg_TwigExtention_Meta());
        $twig->addExtention(new Jhg_TwigExtention_Base());
        $twig->addExtention(new Jhg_TwigExtention_Image());

        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
        $viewRenderer->setView($twig);
        $viewRenderer->setViewBasePathSpec(':moduleDir' . '/views/scripts');
        return $twig;
    }

    protected function _initDb2() {
        try {
            $this->bootstrap('db');
            $db = $this->getResource('db');
            $db->query("SET NAMES UTF8");
            Zend_Registry::set('db', $db);
        } catch (Exception $e) {
            die($e->getMessage());
        }
    }

}

